﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _02_CheckForCorrectExpression
{
    class CheckForCorrectExpression
    {
        static void Main(string[] args)
        {
            Console.Write("Enter the expression: ");
            string expression = Console.ReadLine();

            int leftBrackets = 0;
            int index = expression.IndexOf("(");
            while (index != -1)
            {
                leftBrackets++;
                index = expression.IndexOf("(", index + 1);
            }

            index = expression.IndexOf(")");
            int rightBracket = 0;
            while (index != -1)
            {
                rightBracket++;
                index = expression.IndexOf(")", index + 1);
            }

            if (leftBrackets == rightBracket)
            {
                Console.WriteLine("The expression is correct.");
            }
            else
            {
                Console.WriteLine("The expression is not correct.");
            }
        }
    }
}
